-module(assembler_file).

-author('abdoo.mahran@gmail.com').

-export([open/1, close/1, read_line/1]).

%%% Opens file
open(FileName) ->
    case file:open(FileName, [read, raw]) of
        {ok, Fd} ->
            Fd;
        {error, Reason} ->
            io:format("Couldn't open file ~p because ~p~n", [FileName, Reason])
    end.

%%% Closes file
close(Fd) ->
    case file:close(Fd) of
        ok ->
            ok;
        {error, Reason} ->
            io:format("Couldn't close file because ~p",[Reason])
    end.

%%% Reads line from a file
read_line(Fd) ->
    case file:read_line(Fd) of
        {ok, Data} ->
            Data;
        eof ->
            eof;
        {error, Reason} ->
            io:format("Couldn't read line because ~p~n", Reason)
    end.
